package 最低通行费;

import java.util.*;

public class Main {
    static int N = 110, n;
    static int[][] w = new int[N][N];
    static int[][] f = new int[N][N];

    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        n = in.nextInt();
        for (int i = 1; i <= n; i++) {
            for (int j = 1; j <= n; j++) {
                w[i][j] = in.nextInt();
                if (i == 1 && j == 1) {
                    f[i][j] = w[i][j];
                } else if (i == 1) {
                    f[i][j] = f[i][j - 1] + w[i][j];
                } else if (j == 1) {
                    f[i][j] = f[i - 1][j] + w[i][j];
                }
            }
        }
        for (int i = 2; i <= n; i++) {
            for (int j = 2; j <= n; j++) {
                f[i][j] = Math.min(f[i - 1][j], f[i][j - 1]) + w[i][j];
            }
        }
        System.out.println(f[n][n]);
    }
}
